package com.xiaoq.feature.repository.impl;

import java.util.List;

import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xiaoq.coms.util.IdGeneratorUtils;
import com.xiaoq.feature.entity.VegetRecomEntity;
import com.xiaoq.feature.repository.IVegetRecomRepository;

@Repository
public class VegetRecomRepositoryImpl implements IVegetRecomRepository {
	
	@Autowired
	private Datastore datastore;

	@Override
	public List<VegetRecomEntity> findVegetRecoms(String sitesId) {
		Query<VegetRecomEntity> vegetRecomQuery = datastore.find(VegetRecomEntity.class).field("sitesId")
				.equal(sitesId);
		return vegetRecomQuery.asList();
	}

	@Override
	public VegetRecomEntity findVegetRecomById(String id) {
		Query<VegetRecomEntity> vegetRecomQuery = datastore.find(VegetRecomEntity.class).field(IdGeneratorUtils.IDGENERATOR).equal(id);
		VegetRecomEntity vegetRecomEntity = vegetRecomQuery.get();
		return vegetRecomEntity;
	}

}
